home *** CD-ROM | disk | FTP | other *** search
/ SGI Desktop Special Edition 1.1 / SGI Desktop Special Edition 1.1.iso / dist / mmail.idb / usr / lib / Zmail / sgi.func.z / sgi.func
Encoding:
Text File  |  1995-11-13  |  3.3 KB  |  125 lines

  1. function forward() {
  2.     mail -f
  3. }
  4.  
  5. function gethost() {
  6.     shift 1
  7.     set __hn = "$1"
  8. }
  9.  
  10. function unset_vacation() {
  11.    sh $ZMLIB/bin/unset_vac
  12.    echo -d "Vacation program unset"
  13. }
  14.  
  15. function set_vacation() {
  16.     set __vmessage = $HOME/.vacation.msg
  17.     set __vprogram = /usr/sbin/vacation
  18.     set __reassembler = $ZMLIB/bin/reassembler
  19.     set __interval = 7
  20.     gethost $hostname
  21.         
  22.     # Validate that the vacation program exists.
  23.     if ! -e $__vprogram
  24.        error "Vacation program is not available"
  25.     endif
  26.  
  27.     # Get interval in number of days for vacation message to be resent.        
  28.     ask -i __interval "Reply interval in days:" $__interval
  29.     if $status == -1        # if user cancelled command, return now
  30.        echo "Vacation command cancelled."
  31.        return -1
  32.     endif
  33.  
  34.     # If vacation message file does not exist, create one with appropriate
  35.     # headers.
  36.     if ! -e $__vmessage
  37.        set __from = "From: $LOGNAME@$__hn ($realname)"
  38.        set __subj = "Subject: I am on vacation"
  39.        set __prec = "Precedence: bulk"
  40.        set __mess = "I am out of the office..."
  41.        sh "echo '$__from'\\n$__subj\\n$__prec\\n\\n$__mess > $__vmessage"
  42.     endif
  43.     
  44.     sh jot -f $__vmessage
  45.     sh $__vprogram -i -r $__interval
  46.     sh $ZMLIB/bin/unset_vac
  47.  
  48.     if -e $HOME/.forward
  49.         sh cp $HOME/.forward $HOME/.forward.reassembler
  50.     endif
  51.  
  52.     if $?dot_forward
  53.         sh echo '\|'$__reassembler, \"'\|'$__vprogram -a $LOGNAME@$__hn $LOGNAME\"> $HOME/.forward
  54.     else
  55.         sh echo $LOGNAME, \"'\|'$__vprogram -a $LOGNAME@$__hn $LOGNAME\"> /tmp/.forw$$
  56.         sh "sed 's/\(.*\)/\\\1/' /tmp/.forw$$ > $HOME/.forward"
  57.         sh rm -f /tmp/.forw$$
  58.     endif
  59.  
  60.     sh touch $HOME/.vacation_set
  61.        
  62.     echo -d "Vacation program set"
  63.     
  64. }
  65.  
  66. function vacation() {
  67.     if -e $HOME/.vacation_set
  68.        set __vac_def = "Unset"
  69.        set __vac_choices = "Set"
  70.     else
  71.        set __vac_def = "Set"
  72.        set __vac_choices = "Unset"
  73.     endif
  74.     
  75.     set __vac
  76.     ask -i __vac -m -d $__vac_def "Select Set/Unset Vacation:" $__vac_choices
  77.     if $status == -1        # if user cancelled command, return now
  78.        echo "Vacation command cancelled."
  79.        return -1
  80.     endif
  81.  
  82.     if $__vac == "Set"
  83.        set_vacation
  84.     else 
  85.        unset_vacation
  86.     endif
  87. }
  88.  
  89. if -e /usr/lib/InPerson/inpinvite
  90.     set __InPerson
  91. endif
  92.  
  93. function zmenu_reply_inperson() {
  94.     if $?[%?X-InPerson-Address?]
  95.         set __ipaddr = "$[%?X-InPerson-Address?]"
  96.     else
  97.         set __ipaddr="$[%a]"
  98.     endif
  99.     sh /usr/lib/InPerson/inpinvite -to "$__ipaddr" -subject "$[%s]"
  100. }
  101.  
  102. function print_options() {
  103.     set __print_cmd=$print_cmd
  104.     ask -m -d "Portrait" -i __action "Select Print Options:" "Portrait" "Landscape" "Two pages/sheet" "A4"
  105.     if $status == 0
  106.         if "x$__action" == "xPortrait"
  107.             set print_cmd=$__print_cmd
  108.         else
  109.             if "x$__action" == "xLandscape"
  110.                 set print_cmd="mailp -W170 -p $MP_PROLOGUE/mp.pro.ls.ps %O"
  111.             else
  112.                 if "x$__action" == "xTwo pages/sheet"
  113.                     set print_cmd="mailp -W80 -l %O"
  114.                 else
  115.                     if "x$__action" == "xA4"
  116.                         set print_cmd="mailp -A4 %O"
  117.                     endif
  118.                 endif
  119.             endif
  120.         endif
  121.         lpr
  122.         set print_cmd=$__print_cmd
  123.     endif
  124. }
  125.